package com.yuanfeng.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuanfeng.commoms.vo.order.ShoppingCartVO;
import com.yuanfeng.order.dto.EntityObjectsDTO;
import com.yuanfeng.order.entity.OrderUserCartEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @ClassName OrderUserCartMapper
 * @Description  购物车表
 * @Author cyp
 * @Date 2023-05-25 13:39:40
 * @Version 1.0
 **/
@Mapper
public interface OrderUserCartMapper extends BaseMapper<OrderUserCartEntity> {
     /**
      * 查询商品在购物车的数量
      * @param userId
      * @param goodsId
      * @return
      */
     Integer selectCurrentCartQuantity(@Param("userId")String userId, @Param("goodsId")Integer goodsId);

    /**
     * 下单成功 删除购物车商品
     * @param userId
     * @param goodsIdList
     */
    void batchDeleteGoods(@Param("userId") String userId, @Param("goodsIdList") List<Integer> goodsIdList);

    /**
     * 修改购物车商品数量
     * @param userId
     * @param goodsId
     * @param goodsNum
     * @return
     */
    Boolean changeGoodsNum(@Param("userId") String userId, @Param("goodsId") Integer goodsId,
                           @Param("goodsNum") Integer goodsNum);


    /**
     * 查询店铺名和店铺id
     *
     * @param userId
     * @param goodsType
     * @return
     */
    List<EntityObjectsDTO> queryShoppingCartByShopName(String userId, Integer goodsType);

    /**
     * 平台查看用户购物车
     * @param page
     * @param param
     * @return
     */
    IPage<ShoppingCartVO> getShoppongCartList(IPage<ShoppingCartVO> page , @Param("param") ShoppingCartVO param);



    /**
     * 更新购物车
     *
     * @param map
     * @return
     */
    Integer updateOrderUserCarByMap(@Param("param") Map<String, Object> map);


    /**
     * 更新商品数量
     *
     * @param userId
     * @param goodsId
     * @param goodsNum
     * @return
     */
    Boolean updateGoodsNum(String userId, Integer goodsId, Integer goodsNum,String insertCartTime);

    Integer selectCommonNumByUserId(@Param("userId") String userId,@Param("commonId") Integer commonId);
}

